<?php
/**
 * The Template for displaying all single posts.
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */

get_header(); ?>

		<div id="primary">
			<div id="content" role="main"><div>
				
				<?php while ( have_posts() ) : the_post(); 
					// `get primary meta content
                    $post_id = get_the_ID();
                    $preview_image = get_post_meta($post_id, 'wpcf-preview-image', true);
                    $preview_url = get_post_meta($post_id, 'wpcf-preview-url', true);
                    $download_url = get_post_meta($post_id, 'wpcf-download-file', true);
                    $features = get_post_meta($post_id, 'wpcf-features');
                    $content = get_post_meta($post_id, 'wpcf-content', true);                    
                ?>
                <h1><? the_title(); ?></h1>
                <div class="post-body" data="<?php echo $post_id; ?>">
                	<img class="preview-image" src="<?php echo $preview_image; ?>" alt="preview-image"/>
                	<div class="post-app-buttons">
                		<a data="<?php echo $post_id;?>" href="<?php echo $preview_url; ?>" class="btn-org preview" target="_blank">Preview</a>
                		<a data="<?php echo $post_id;?>" href="<?php echo $download_url; ?>" class="btn-org download" target="_blank">Download</a>
                		<?php edit_post_link();?>
                	</div>
                	<h2>Features</h2>
                	<div class="feature-list">
                		<?php 
                		$count = count($features);
                		for ($i = 0; $i < $count; $i++) {
                			echo '<li>'.$features[$i].'</li>';
                		}
                		?>
                	</div>
                	<h2>Guide</h2>
                	<div class="content">
                		<?php echo $content;?>
                	</div>
                </div>
				<?php comments_template( '', true ); ?>

				<?php endwhile; // end of the loop. ?>

			</div></div><!-- #content -->			
			<?php get_sidebar(); ?>
		</div><!-- #primary -->
		<script type="text/javascript" src="<?php echo get_template_directory_uri(); ?>/js/single.js"></script>
<?php get_footer(); ?>